import Vue from 'vue'
import Router from 'vue-router'

// import System from './views/system/System.vue';
import Home from './components/common/Home.vue';

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      component: resolve => require(['./components/LogInToRegister/Login.vue'], resolve),
    },
    {
      path: '/forgetPsd',
      component: resolve => require(['./components/LogInToRegister/forgetPsd.vue'], resolve),
    },
    {
      path: '/',
      name: 'system',
      component: Home,
      children: [{
          path: '/firstPage',
          component: resolve => require(['./components/pingtai/firstPage.vue'], resolve),
        },
        //段华蓉的路由 开始
        {
          path: '/order',
          component: resolve => require(['./components/orders/order.vue'], resolve),
        },
        //崔宸瑜 路由开始
        {
          path: '/changePsd',
          component: resolve => require(['./components/LogInToRegister/changePsd.vue'], resolve),
        },
        {
          path: '/home',
          component: resolve => require(['./components/shops/home.vue'], resolve),//桂飞的路由 开始
        },
        //周荣芳的路由 开始
        {
          path: '/addgoods',
          component: resolve => require(['./components/goods/addgoods.vue'], resolve),
        },
        {
          path: '/showgoods',
          component: resolve => require(['./components/goods/showgoods.vue'], resolve),
        },
        //李可路由开始
        {
          path: '/mendianlist',
          component: resolve => require(['./components/mendian/mendianlist.vue'], resolve),
        },
        //伍鹏路由开始
        {
          path: '/applyList',
          component: resolve => require(['./components/applyManage/applyList.vue'], resolve),
        },
        {
          path: '/managePersonList',
          component: resolve => require(['./components/applyManage/managePersonList.vue'], resolve),
        }
      ]
    },
  ],
})
router.beforeEach((to, from, next) => {
  if (to.path === '/firstPage') {
    if (localStorage.user) {
      next()
    } else {
      confirm("请先登录");
      next(false)
    }
  } else {
    next()
  }
})

export default router